/******************************************************************************
** 
** Print what won't fit. 
** 
** File name:	more_than_80.c
** Compilation:	cc more_than_80.c -o more_than_80
** Execution:	./more_than_80
** 
** Description:
** Reads the input, divides it into strings and echoes only the strings that 
** are longer than 80 symbols.
** 
******************************************************************************/
#include <stdio.h>

#define MAX_LINE_LENGTH 1000
#define FILTERED_STRING_LENGTH 80

int get_line(char line[], int max_length);

int current_length;
char current_line[MAX_LINE_LENGTH];

int main()
{

    extern int current_length;
    extern char current_line[MAX_LINE_LENGTH];
    
    current_length = 0;
    while ((current_length = get_line(current_line, MAX_LINE_LENGTH)) != 0) {
        if (current_length >= FILTERED_STRING_LENGTH) {
            printf("\n* %d characters long: %s\n", current_length, current_line);
        }
    }

    return 0;
}


// get_line: Reads one line from the input and stores it in the array, returns line length.
int get_line(char line[], int max_length) {
    int c, i;

    for (i=0; i<max_length && (c=getchar()) != EOF && c != '\n'; ++i) {
        line[i] = c;
    }
    if (c == '\n') {
        line[i] = c;
        ++i;
    }
    line[i] = '\0';
    return i;
}
